package com.utils;

import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class Tool {

    /**
     * 生成 md5
     * @param pwd 原密码
     */
    public static String generateMd5(String pwd) {
        MessageDigest md5 = null;
        try {
            md5 = MessageDigest.getInstance("MD5");
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }
        md5.update(pwd.getBytes());

        return new BigInteger(1, md5.digest()).toString(16);
    }

    /**
     * 判断值是否为空
     * @param value 值
     */
    public static Boolean isNull(String value) {
        return value == null || value.trim().length() == 0;
    }

}